<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>资金管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../../include/commonFile.jsp" %>
</head><body>
<!--头部-->
<%@include file="../../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
           <%-- <%@include file="fundManaIndex.jsp" %>--%>
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li class="layui-this"><span class="title f18 ml5 mr5">全部资金</span></li>
                    <li><span class="title f18 ml5 mr5">众筹资金</span></li>
                    <li><span class="title f18 ml5 mr5">活动资金</span></li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <form class="layui-form" action="${ctx}/order/order/orderList.do" id="myForm" method="post">
                            <input type="hidden" name="pageNo" id="pageNo"/>
                            <div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">订单名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="title" class="layui-input" value="${orderForm.title}" placeholder="请输入查询订单名称">
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable" style="margin-left: 14px;">下单者</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="memberName" class="layui-input" value="${input.memberName}" placeholder="请输入查询订单下单者" >
                                            </div>
                                        </li>
                                        <li class="form-item-inline">
                                            <div class="sub-btns">
                                                <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">确定</a>
                                                <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                            </div>
                                        </li>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item"><label class="search-form-lable">订单类型</label>
                                            <div class="check-btn-inner">
                                                <a id="all" href="javascript:void(0);" onclick="setTimeType($(this),'','#myForm')" ${empty orderForm.type ? 'class="active"' : ''}>全部</a>
                                                <c:forEach var="map" items="${orderTypes}">
                                                    <a href="javascript:void(0);" onclick="setTimeType($(this),'${map.key}','#myForm')" ${orderForm.type == map.key ? 'class="active"' : ''}>${map.value}</a>
                                                </c:forEach>
                                                <input type="hidden" name="type" value="${orderForm.type}" />
                                            </div>
                                        </li>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item"><label class="search-form-lable">下单时间</label>
                                            <div class="check-btn-inner" id="timeType">
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),4,'#myForm')" ${input.timeType == 4 ? 'class="active"' : ''}>昨天</a>
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                                <input type="hidden" name="timeType" value="${input.timeType}" />
                                            </div>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="createStart" value="${input.createStart}" placeholder="开始日">
                                                </div>
                                                -
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="createEnd" value="${input.createEnd}" placeholder="截止日">
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </form>
                        <div class="my-act-list-content">
                            <ul class="num">
                                <div class="l">
                                    <li class="f16">收入总金额
                                        <span class="red">
											<c:if test="${orderTotal > 0}">
                                                <fmt:formatNumber pattern="#,###.##" value="${orderTotal}"/>
                                            </c:if>
											<c:if test="${orderTotal == 0.0}">
                                                ${orderTotal}
                                            </c:if>
										</span> 元
                                    </li>
                                </div>
                                <div class="r">
                                    <li style="cursor: pointer;" class="r"><a class="layui-btn layui-btn-danger layui-btn-sm" href="javascript:txz.expireCheck('', function() { exportExcelData() })">导出EXCEL</a></li>
                                </div>
                                <p class="cl"></p>
                            </ul>
                            <div class="cl">
                                <table class="layui-table">
                                    <colgroup>
                                        <col>
                                        <col>
                                        <col>
                                        <col width="150px">
                                        <col width="150px">
                                        <col width="150px">
                                        <col width="150px">
                                        <col width="150px">
                                        <col width="110px">
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>订单名称</th>
                                        <th>下单者</th>
                                        <th>商户</th>
                                        <th>订单类型</th>
                                        <th>金额</th>
                                        <th>订单状态</th>
                                        <th>支付方式</th>
                                        <th>下单时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:if test="${page.totalCount == 0}">
                                        <tr>
                                            <td colspan="8">
                                                <div class="f16 tc">还没有明细记录</div>
                                            </td>
                                        </tr>
                                    </c:if>
                                    <c:forEach var="orderForm" items="${orderForms}">
                                        <tr>
                                            <td title="${orderForm.title}" onclick="openDialogNoButton('订单详情','${ctx}/order/order/orderInfo.do?id=${orderForm.id}','450px','570px')">
                                                <div class="member-name ellipsis-1 blue" style="cursor: pointer">${orderForm.title}</div>
                                            </td>
                                            <td class="table-member"
                                                onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${orderForm.memberId}','400px','470px')">
                                                <div class="member-cell">
                                                <div class="member-logo common-img"
                                                    >
                                                    <img src="<c:if test="${ orderForm.member.logo!= null}">${orderForm.member.logo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                </div>
                                                <div class="member-name ellipsis-1">
                                                    <a class="blue" title="${orderForm.member.realname}" style="cursor: pointer;">${orderForm.member.realname}</a>
                                                </div>
                                                </div>
                                            </td>
                                            <td>${orderForm.merchantName}</td>
                                            <td>${orderForm.typeName}</td>
                                            <td>￥${orderForm.payment}</td>
                                            <td>
                                                <c:choose>
                                                    <c:when test="${orderForm.status == 0}">
                                                        <span>审核中</span>
                                                    </c:when>
                                                    <c:when test="${orderForm.status == 1}">
                                                        <span>待支付</span>
                                                    </c:when>
                                                    <c:when test="${orderForm.status == 2}">
                                                        <span style="color: red;">已支付</span>
                                                    </c:when>
                                                    <c:when test="${orderForm.status == 3}">
                                                        <span>其它</span>
                                                    </c:when>
                                                    <c:when test="${orderForm.status == 4}">
                                                        <span>已退款</span>
                                                    </c:when>
                                                </c:choose>
                                            </td>
                                            <td>
                                                <div>
                                                    <c:choose>
                                                        <c:when test="${orderForm.paymentWay == 1}">微信</c:when>
                                                        <c:when test="${orderForm.paymentWay == 0}">支付宝</c:when>
                                                    </c:choose>
                                                </div>
                                            </td>
                                            <td><fmt:formatDate value="${orderForm.updateDate}" pattern="yyyy-MM-dd HH:mm"/></td>
                                            <td>
                                                <c:if test="${orderForm.type == 3}"><a href="javascript:showAuthor('${orderForm.id}')" class="red">查看众筹者</a></c:if>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="page-content">
                            <div id="page_content" class="page-container"></div>
                            <div class="cl"></div>
                        </div>
                    </div>
                    <div class="layui-tab-item"></div>
                    <div class="layui-tab-item"></div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../../include/footer.jsp" %>
    </section>
    <div id="authorDialog">
        <table class="layui-table" lay-skin="line">
            <tbody>
            <tr>
                <td class="table-member">
                    <div class="member-cell">
                        <div class="member-logo"></div>
                        <div class="member-name ellipsis-1">
                            <a href="javascript:void(0);"></a>
                        </div>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript">
    $(function () {

        txz.initHeader({
            nav:[ {
                name: '资金管理',
                curr: true
            }]
        });

        layui.use([ 'element' ], function() {
            var element = layui.element;

            element.on('tab', function (data) {
                if (data.index == 0) {
                    location.href = "${ctx}/order/order/orderList.do";
                } else if(data.index == 1){
                    location.href = "${ctx}/order/order/withdrawList.do";
                } else if (data.index == 2) {
                    //location.href = "${ctx}/order/order/tradeList.do";
                    location.href = "${ctx}/charge/package/packageMemberList.do";

                }
            });
        });

        //加载分页
        loadPageNew({elem: 'page_content',totalCount: '${page.totalCount}',limit: '${page.limit}',page: '${page.page}'});

        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })

    function showAuthor(orderId) {
        var setPayIndex = layer.open({
            type: 1,
            area: '400px',
            title: '查看众筹者',
            content: $("#authorDialog"),
            btn: ['关闭'],
            success: function () { // 弹出后回调
                $.get('${ctx}/crowdfund/project/getProjectAuthorByOrder.do', {'orderId': orderId}, function (res) {
                    if (res.success) {
                        var logo = res.data.authorLogo;
                        if (logo) {
                            $("#authorDialog").find(".member-logo").css('background-image', 'url(' + logo + '?imageMogr2/auto-orient/crop/126x126)');
                        } else {
                            $("#authorDialog").find(".member-logo").css('background-image', 'url(${ctx}/image/def_user_logo.png)');
                        }
                        $("#authorDialog").find(".member-name a").text(res.data.authorName);
                    } else {
                        util.layerMsgError("查看众筹者失败");
                    }
                })
            },
            end: function () { // 销毁后回调
                $("#authorDialog").find(".member-logo").css('background-image', '');
                $("#authorDialog").find(".member-name a").text('');
            },
            yes: function () { // 确定按钮
                layer.close(setPayIndex);
            }
        });
    }

    function exportExcelData() {
        layer.confirm('确认要导出Excel吗?', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var url = "${ctx}/wallet/exportOrder.do";

            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            $.post(url, $("#myForm").serialize(), function (res) {
                top.layer.close(loadIndex);
                if (res.success) {
                    window.location.href = res.data;
                } else {
                    util.layerMsgError(res.description)
                }
            });
            top.layer.close(index);
        });
    }
</script>
</body>
</html>